package com.ryskoo.customer.vendorinfo.domain;

import com.ryskoo.common.constant.SystemConstant;
import com.ryskoo.framework.core.bean.BasicPO;
import com.ryskoo.framework.core.utils.DateFormatHelper;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * @author hh
 */
@Entity
@Table(name = "CUS_VENDOR_INFO")
public class VendorInfoPO extends BasicPO {
	
	private static final long serialVersionUID = 2180831740460042817L;

	/** 商户主表uuid */
    @Column(name = "vendor_uuid", length = 32)
    private String vendorUuid;
    
	/** 联系人名称 */
    @Column(name = "contact_name", length = 30)
    private String contactName;
    
    /** 联系人手机号 */
    @Column(name = "contact_mobile", length = 14)
    private String contactMobile;
    
    /** 联系人邮箱 */
    @Column(name = "contact_email", length = 32)
    private String contactEmail;
    
    /** 联系人地址(省编码) */
    @Column(name = "contact_province", length = 12)
    private String contactProvince;
    
    /** 联系人地址(市编码) */
    @Column(name = "contact_city", length = 12)
    private String contactCity;
    
    /** 联系人地址(区编码) */
    @Column(name = "contact_region", length = 12)
    private String contactRegion;
    
    /** 联系人地址(街道编码) */
    @Column(name = "contact_street", length = 12)
    private String contactStreet;
    
    /** 联系人地址(详细地址) */
    @Column(name = "contact_address", length = 50)
    private String contactAddress;
    
    /** 联系人地址(省市区中文名) */
    @Column(name = "contact_area", length = 50)
    private String contactArea;
    
	/* 商户所在经度 */
    @Column(name = "longitude", length = 12)
	private String longitude;
    
	/* 商户所在纬度 */
    @Column(name = "latitude", length = 12)
	private String latitude;
    
	/** 开始营业时间  时分格式，如：09:00  */
	@Column(name = "begin_time", columnDefinition = "char(5)", length = 5)
	private String beginTime;
	
	/** 结束营业时间  时分格式，如：23:00  */
	@Column(name = "end_time", columnDefinition = "char(5)", length = 5)
	private String endTime;
	
	/** 营业状态 0表示打烊 1表示正在营业,默认正在营业  */
	@Column(name = "operation_status", columnDefinition = "char(1)", length = 1)
	private String operationStatus = SystemConstant.CONSTANT_ONE_STR;
	
	/** 积分换算-一元等于多少积分 */
	@Column(name = "integral_num", columnDefinition = "int")
	private int integralNum = SystemConstant.CONSTANT_ZERO;
	
	/** 评价送积分，赠送积分数 */
	@Column(name = "appraise_integral", columnDefinition = "int")
	private int appraiseIntegral = SystemConstant.CONSTANT_ZERO;
	
	/** 商家是否营业 （根据营业状态和营业时间判断） */
    @Transient
    private boolean isOpen = SystemConstant.CONSTANT_TRUE;
	
    @Transient
	private String contactProvinceName;
	@Transient
    private String contactCityName;
	@Transient
	private String contactRegionName;
	@Transient
	private String contactStreetName;

	public int getAppraiseIntegral() {
		return appraiseIntegral;
	}

	public void setAppraiseIntegral(int appraiseIntegral) {
		this.appraiseIntegral = appraiseIntegral;
	}

	public String getVendorUuid() {
		return vendorUuid;
	}

	public void setVendorUuid(String vendorUuid) {
		this.vendorUuid = vendorUuid;
	}

	public String getContactName() {
		return contactName;
	}

	public void setContactName(String contactName) {
		this.contactName = contactName;
	}

	public String getContactMobile() {
		return contactMobile;
	}

	public void setContactMobile(String contactMobile) {
		this.contactMobile = contactMobile;
	}

	public String getContactEmail() {
		return contactEmail;
	}

	public void setContactEmail(String contactEmail) {
		this.contactEmail = contactEmail;
	}

	public String getContactProvince() {
		return contactProvince;
	}

	public void setContactProvince(String contactProvince) {
		this.contactProvince = contactProvince;
	}

	public String getContactCity() {
		return contactCity;
	}

	public void setContactCity(String contactCity) {
		this.contactCity = contactCity;
	}

	public String getContactRegion() {
		return contactRegion;
	}

	public void setContactRegion(String contactRegion) {
		this.contactRegion = contactRegion;
	}

	public String getContactStreet() {
		return contactStreet;
	}

	public void setContactStreet(String contactStreet) {
		this.contactStreet = contactStreet;
	}

	public String getContactAddress() {
		return contactAddress;
	}

	public void setContactAddress(String contactAddress) {
		this.contactAddress = contactAddress;
	}

	public String getContactArea() {
		return contactArea;
	}

	public void setContactArea(String contactArea) {
		this.contactArea = contactArea;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(String beginTime) {
		this.beginTime = beginTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public int getIntegralNum() {
		return integralNum;
	}

	public void setIntegralNum(int integralNum) {
		this.integralNum = integralNum;
	}

	public String getContactProvinceName() {
		return contactProvinceName;
	}

	public void setContactProvinceName(String contactProvinceName) {
		this.contactProvinceName = contactProvinceName;
	}

	public String getContactCityName() {
		return contactCityName;
	}

	public void setContactCityName(String contactCityName) {
		this.contactCityName = contactCityName;
	}

	public String getContactRegionName() {
		return contactRegionName;
	}

	public void setContactRegionName(String contactRegionName) {
		this.contactRegionName = contactRegionName;
	}

	public String getContactStreetName() {
		return contactStreetName;
	}

	public void setContactStreetName(String contactStreetName) {
		this.contactStreetName = contactStreetName;
	}

	public String getOperationStatus() {
		return operationStatus;
	}

	public void setOperationStatus(String operationStatus) {
		this.operationStatus = operationStatus;
	}

	public boolean isOpen() {
		//如果商家打烊，直接返回false
		if (SystemConstant.CONSTANT_ZERO_STR.equals(this.getOperationStatus())) {
			return false;
		}
		
		//如果当前时间小于营业开始时间，或者大于营业结束时间，返回flase
		String nowTime = DateFormatHelper.getTimeStr(DateFormatHelper.FORMAT_DATE_STR3, new Date());
		if (DateFormatHelper.compareTime(nowTime, this.beginTime + ":00",DateFormatHelper.FORMAT_DATE_STR3)
				|| DateFormatHelper.compareTime(this.endTime + ":00", nowTime,DateFormatHelper.FORMAT_DATE_STR3)) {
			return false;
		}
		
		return true;
	}

	public void setOpen(boolean isOpen) {
		this.isOpen = isOpen;
	}
	
}
